<template>
	<cmDialog v-model="visible" :modal-title="update ? '详情' : '详情'">
		<el-descriptions title="" border column="2">
			<el-descriptions-item label="登录账号">{{ state.detailUserForm.loginName }}</el-descriptions-item>
			<el-descriptions-item label="用户中文名称">{{ state.detailUserForm.cnName }}</el-descriptions-item>
			<el-descriptions-item label="角色编码">{{ state.detailUserForm.roleCode }}</el-descriptions-item>
			<el-descriptions-item label="代码(建管平台)">{{ state.detailUserForm.rydm }}</el-descriptions-item>
			<el-descriptions-item label="单位编号">{{ state.detailUserForm.dwdm }}</el-descriptions-item>
			<el-descriptions-item label="单位名称">{{ state.detailUserForm.dwmc }}</el-descriptions-item>
			<el-descriptions-item label="创建时间">{{ state.detailUserForm.createTime }}</el-descriptions-item>
			<el-descriptions-item label="更新时间">{{ state.detailUserForm.updateTime }}</el-descriptions-item>
			<el-descriptions-item label="备注">{{ state.detailUserForm.remark }}</el-descriptions-item>
			<el-descriptions-item v-if="state.detailUserForm.iflag" label="状态">正常</el-descriptions-item>
			<el-descriptions-item v-else label="状态">禁止</el-descriptions-item>
		</el-descriptions>
	</cmDialog>
</template>
<script lang="ts" setup>
import { userDetailApi } from '@/api/system/rbac'
import cmDialog from '@/components/cm-dialog/index.vue'
import type { FormInstance } from 'element-plus'
import { reactive, ref } from 'vue'

const detailUserRef = ref<FormInstance>()
const visible = ref(false)
const update = ref(false)

const state = reactive({
	detailUserForm: {
		loginName: '',
		cnName: '',
		roleCode: '',
		rydm: '',
		dwdm: '',
		dwmc: '',
		createTime: '',
		updateTime: '',
		remark: '',
		iflag: ''
	}
})

const init = (isUpdate: boolean, row: any) => {
	visible.value = true
	// update.value = isUpdate

	if (isUpdate) {
		// isUpdate  true-新增  、false-编辑row有数据 反显
		// 重置画面数据
	}
	userDetailMethod(row)
}
interface paramObject {
	id?: Number
}

const userDetailMethod = async (data: paramObject) => {
	let queryParam = {
		id: data.id
	}
	await userDetailApi(queryParam).then(res => {
		// console.log("获取角色详情", res.data)
		Object.assign(state.detailUserForm, res.data)
	})
}
const handleAddCancel = () => {
	visible.value = false
}

defineExpose({
	init
})
</script>
<style scoped>
.dialog-foot {
	text-align: center;
}
</style>
